﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EnrollmentSystem
{
    public partial class frmScheduleList : Form
    {
        string selected = "";
        int selectedindex = -1;
        public frmScheduleList()
        {
            InitializeComponent();
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            btnSelect.Click += new EventHandler(delegate
            {
                if (lstSched.SelectedIndex == -1)
                {
                    MessageBox.Show("Please select a schedule first.", "Schedule Select", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                selected = lstSched.SelectedItem.ToString();
                selectedindex = lstSched.SelectedIndex;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            });
            lstSched.DoubleClick += new EventHandler(delegate
            {
                if (lstSched.SelectedIndex == -1)
                {
                    MessageBox.Show("Please select a schedule first.", "Schedule Select", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                selected = lstSched.SelectedItem.ToString();
                selectedindex = lstSched.SelectedIndex;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            });
        }
        
        //Public members
        public void AddRange(string[] dat)
        {
            lstSched.Items.AddRange(dat);
        }
        public string GetSchedule()
        {
            return selected;
        }
        public int GetScheduleID()
        {
            return selectedindex;
        }
    }
}
